import request from '@/utils/request'
import { transformQueryCondition } from '@/utils'
import store from '../../store'

const subSysPrefix = '/bussSys'

// 业务系统与用户关系检索
export function systemManagerSelect(postselectinfo) {
  postselectinfo.userid = store.getters.userid
  return request({
    url: subSysPrefix + '/SystemManager/select',
    method: 'post',
    data: postselectinfo
  })
}

// 业务系统与用户关系插入
export function systemManagerInsert(postselectinfo) {
  postselectinfo.userid = store.getters.userid
  return request({
    url: subSysPrefix + '/SystemManager',
    method: 'post',
    data: postselectinfo
  })
}
// 业务系统与用户关系删除
export function systemManagerDelete(postselectinfo) {
  // postselectinfo.userid = store.getters.userid
  return request({
    url: subSysPrefix + '/SystemManager/force',
    method: 'DELETE',
    data: postselectinfo
  })
}

// 检索
export function getNoSelectedManagers(data) {
  let searchCon = transformQueryCondition(data)
  delete searchCon.userId
  return request({
    url: subSysPrefix + '/SystemManager/selectNotSelected',
    method: 'post',
    params: {
      systemId: data.systemId
    },
    data: searchCon
  })
}

// 业务系统与用户关系检索
export function systemManagerCompositeSelect(postselectinfo) {
  postselectinfo.userid = store.getters.userid
  return request({
    url: subSysPrefix + '/SystemManager/compositeSelect',
    method: 'post',
    data: postselectinfo
  })
}
